home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SplashWindow.cp
-
- Contains: a simple splash screen window
-
- Written by: Dave Falkenburg
-
- Copyright: © 1993-1995 by Dave Falkenburg, all rights reserved.
-
- Change History (most recent first):
-
- <8> 1/20/95 DRF Fix a double-dispose bug: there is no need to get rid of a
- window’s picture. DisposeWindow will already KillPicture it.
- <7> 1/3/95 DRF Only show the splash window if there is a splash screen picture.
- <6> 11/16/94 DRF Add (StringPtr) cast to make PPCC happier.
- <5> 11/12/94 DRF Use NewColorOrBlackAndWhiteWindow.
- <4> 11/8/94 DRF Deal with a missing splash picture.
- <3> 9/27/94 DRF AppLib.h is now Sprocket.h
- <2> 9/9/94 DRF Reordered headers and removed redundant #includes.
- */
-
- #include "Sprocket.h"
- #include "SplashWindow.h"
-
- #include <ToolUtils.h>
- #include <Resources.h>
-
-
- TSplashWindow::TSplashWindow()
- {
- this->CreateWindow(kNormalWindow);
- }
-
-
- WindowRef
- TSplashWindow::MakeNewWindow(WindowRef behindWindow)
- {
- GrafPtr oldPort;
- Rect splashPictRect,windowRect;
- WindowRef splashWindow;
-
- GetPort(&oldPort);
-
- fSplashPicture = GetPicture(kSplashPictureID);
-
- if (fSplashPicture)
- {
- MoveHHi((Handle) fSplashPicture); // get it out of the way
- splashPictRect = (**fSplashPicture).picFrame;
- }
- else
- SetRect(&splashPictRect,0,0,0,0);
-
- // normalize the rectangle
- OffsetRect(&splashPictRect,-splashPictRect.left,-splashPictRect.top);
-
- // center it on the main screen
- windowRect = splashPictRect;
- OffsetRect(&windowRect,((qd.screenBits.bounds.right-windowRect.right) >> 1),((qd.screenBits.bounds.bottom-windowRect.bottom) >> 1));
-
- splashWindow = NewWindow(nil,&windowRect,(StringPtr) "\p",false,dBoxProc,behindWindow,false,(long) this);
-
- if (fSplashPicture)
- {
- DetachResource((Handle) fSplashPicture); // need to do so we don’t botch the resource map after closing
- SetWindowPic(splashWindow,fSplashPicture); // in case an Alert comes up
-
- ShowWindow(splashWindow);
-
- SetPortWindowPort(splashWindow);
- BeginUpdate(splashWindow); // avoid a flashing update event later
- if (fSplashPicture)
- DrawPicture(fSplashPicture,&splashPictRect);
- EndUpdate(splashWindow); // avoid a flashing update event later
- }
-
- SetPort(oldPort);
- return splashWindow;
- }
-